import Vue from 'vue';
import Vuex from 'vuex';
// eslint-disable-next-line import/extensions
// import user from '@/store/modules/user';
import { getLocal, setLocal, delLocal } from '@/utils/storage';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    token: getLocal('TOKEN'),
  },
  getters: {
  },
  mutations: {
    SET_TOKEN(state, val) {
      // 保存token时对token进行数据持久化
      setLocal('TOKEN', val);
      state.token = val;
    },
    DEL_TOKEN(state) {
      state.token = '';
      // 给localStorage中的token设置为null
      // setLocal('TOKEN', null);
      delLocal('TOKEN');
    },
  },
  actions: {
  },
  modules: {
    // user,
  },
});
